INTENG-21262 Fix for Duplicate purchase events (cached). #1433
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reference
https://branch.atlassian.net/browse/INTENG-21262
Summary
Issue : SDK sends Duplicate purchase events on cold launch of app if network request processing failed in previous launches.
SDK archives a copy of its Request Queue on Disk. Its a txt file (
BNCServerRequestQueue
)stored inside theApplication Support
folder of the data container of app. This archived copy is updated at regular intervals using a timer.When app is cold launched, SDK reads this file and adds requests left unprocessed from last run in its Request Queue.
Because of a bug in SDK, this archived file was not deleted from disk if current request queue is empty. As a result, SDK keeps sending these cached requests on every cold launch of app.
Steps for reproducing bug :
Type Of Change
Testing Instructions
-> Check all unit tests pass.
-> Verify fix -
- Create
BNCServerRequestQueue
archive file using steps mentioned above (Steps 1-4). On my system its stored at path/Users/nidhi.dixit/Library/Developer/CoreSimulator/Devices/9C999B8A-A12B-4DDC-9A7E-A7F9DE201024/data/Containers/Data/Application/FD451857-78A8-4C5A-88C3-7CC9932D931C/Library/Application\ Support/io.branch
. I am testing using simulator.- Cold Lauch App and check all failed requests in previous launch are processed.
BNCServerRequestQueue
file is deleted / updated and it does not contain processed requests anymore.- Cold Launch App again and check SDK is not sending duplicate purchase events.
cc @BranchMetrics/saas-sdk-devs for visibility.